#include <myheader_c_plus.h>
#define COMPETITOR_NUM 5
#define JUDGER_NUM 10
using std::string;
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::deque;
template<typename Container>
void display(Container & con){
    for(auto ele : con){
        cout << ele << " ";
    }
    cout << endl;
}
class Person{
public:
    Person()
    :_name(new char[1]())
    {

    }

    Person(char * name)
    :_name(new char[strlen(name) + 1]())
    {
        total_competitors += 1;
        strcpy(_name, name);
    }

    Person(const Person & rhs)
    :_name(new char[strlen(rhs._name) + 1]())
    {
        total_competitors += 1;
        strcpy(_name, rhs._name);

    }

    Person & operator=(const Person & rhs){
        if(this != &rhs){
            delete [] _name;
            _name = new char[strlen(rhs._name) + 1]();
            strcpy(_name, rhs._name);
        }
        return *this;
    }

    void getAverage(){
        //获取十个评委的分数
        float score;
        cout << "请给" << _name << "打分：请输入入十个评委的分数:" << endl;
        for(int i = 0; i < JUDGER_NUM; ++i){
            cin >> score;
            judgeer_score.push_back(score);
        }

        std::sort(judgeer_score.begin(), judgeer_score.end());
        judgeer_score.pop_back();
        judgeer_score.pop_front();
        float sum = 0;
        for(auto & ele : judgeer_score){
            sum += ele;
        }
        _score = sum / JUDGER_NUM;
        cout << "_score = " << _score << endl;

    }


    void print(){
        cout << _name << ": " << _score << endl;
    }



private:
    char *_name;
    float _score = 0.0;
    deque<float> judgeer_score;
    static int total_competitors;
};
int Person::total_competitors = 0;
int main(int argc, char *argv[])
{
    string name;
    vector<Person> competitors;
    cout << "请输入选手姓名：" << endl;
    for(int i = 0; i < COMPETITOR_NUM; ++i){
        cin >> name;
        competitors.push_back(Person(const_cast<char *>(name.c_str())));
    }
    for(auto & ele : competitors){
        ele.getAverage();
    }
    cout << "选手成绩为:" << endl;

    for(auto & ele : competitors){
        ele.print();
    }
    return 0;
}

